import axios, { type AxiosResponse, AxiosInterceptorManager } from "axios"

export type Status = "success" | "fail"

export interface UploadSuccess {
  status: Status,
  data: string[]
}
export interface SaveImgNum {
  status: Status,
  len: number
}
export interface GetImgs {
  status: Status,
  data: string[]
}

export interface UploadError {
  status: "error"
  message: string
}

// 默认值
axios.defaults.baseURL = import.meta.env.VITE_HTTP_TYPE + import.meta.env.VITE_PREFIX_URL
axios.defaults.timeout = Number(import.meta.env.VITE_TIME_OUT)

// 拦截器
axios.interceptors.response.use(res => {
  // 对响应数据 do something
  return res.data
}, err => {
  return Promise.reject(err)
})

export default axios
